package com.wlz.controller;


import com.wlz.bean.User;
import com.wlz.dao.UserRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * wlz
 *
 * http://bat.ke.qq.com
 * 往期视频加群:516212256 暗号:6
 */
@RestController
public class UserController {

    @Autowired
    private UserRepository userRepository;

    @RequestMapping("/user/save")
    public boolean save(@RequestParam String name){
        User user = new User();
        user.setName(name);
        return userRepository.save(user);
    }

    @GetMapping("/user/list")
    public List<User> list(){

        return (List<User>) userRepository.findAll();
    }
}
